<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
</head>
<body>
    <div class="layui-form timo-compile">
    <form th:action="@{/ad/adInfo/save}">
        <input type="hidden" name="id" th:if="${adInfo}" th:value="${adInfo.id}">
       
       <!--  <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="title" placeholder="请输入标题" th:value="${adInfo?.title}">
            </div>
        </div> -->
        <div class="layui-form-item">
            <label class="layui-form-label">首页图片</label>
           
            <div class="layui-input-inline">
            <input class="layui-input" id="img" type="text" name="img" th:value="${adInfo?.img}">
            <button type="button" class="layui-btn" id="test1">
                 <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
            <img alt="" id="imgshow" th:src="${adInfo?.img}" width="100px" height="100px">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">详情图片</label>
           
            <div class="layui-input-inline">
            <input class="layui-input" id="detailimg" type="text" name="detailimg" th:value="${adInfo?.detailimg}">
            <button type="button" class="layui-btn" id="testdetail">
                 <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
            <img alt="" id="imgdetailshow" th:src="${adInfo?.detailimg}" width="100px" height="100px">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">广告类型</label>
            <div class="layui-input-inline">
                <select class="timo-search-select" name="adtypeid" mo:dict="AD_TYPE" mo-selected="${adInfo?.adtypeid}"></select>
             </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-block">
                <input class="layui-input test-item" type="text" lay-verify="date" name="startTime" id="startTime" placeholder="开始" th:value="${adInfo?.startTime}">

            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
                <input class="layui-input test-item" lay-verify="date" type="text" id="endTime" name="endTime" placeholder="结束" th:value="${adInfo?.endTime}">

            </div>
        </div>

       <!--  <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="num" placeholder="请输入排序" th:value="${adInfo?.num}">
            </div>
        </div> -->
        <div class="layui-form-item timo-finally">
            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
<script th:replace="/common/template :: script"></script>
<script type="text/javascript" th:src="@{/js/plugins/jquery-3.3.1.min.js}"></script>

<script>
 layui.use(['upload','laydate'], function(){
  var upload = layui.upload;

  //执行实例
  var uploadInst = upload.render({
    elem: '#test1' //绑定元素
    ,field: 'picture'
    ,exts: 'jpg|png|gif|jpeg'
    ,auto: true
    ,url: '/upload/picture' //上传接口
    ,done: function(res){
      //上传完毕回调
       $("#img").attr("value",res.data.url);
       $("#imgshow").attr("src",res.data.url);
    }
    ,error: function(){
      //请求异常回调
    }
  });
  
  //执行实例
  var uploadInst = upload.render({
    elem: '#testdetail' //绑定元素
    ,field: 'picture'
    ,exts: 'jpg|png|gif|jpeg'
    ,auto: true
    ,url: '/upload/picture' //上传接口
    ,done: function(res){
      //上传完毕回调
       $("#detailimg").attr("value",res.data.url);
       $("#imgdetailshow").attr("src",res.data.url);
    }
    ,error: function(){
      //请求异常回调
    }
  });

     var laydate = layui.laydate;

     //同时绑定多个

     lay('.test-item').each(function() {

         laydate.render({

             type: 'datetime',

             elem : this,

             trigger : 'click'

         });

     });

 });
</script>
</body>
</html>